<%@page import="java.util.List"%>
<%@page import="com.kensure.shike.constant.BusiConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<jsp:include page="base/header.jsp" flush="true"> 
 <jsp:param value="商品利润核算" name="pageTitle"/>
</jsp:include>

<!--必要样式-->
<link rel="stylesheet" href="<%=BusiConstant.context%>/common/css/style.css" type="text/css" />
<body>
<jsp:include page="base/nav.jsp" flush="true"></jsp:include>

<div id="content" style="margin-left:20px;font-size:12px;">
	<br>
    <div style="height:40px;">
	    <form id="chaxun">
	    	<span style="float:none;margin-right:5px;">商品编号</span>
	        <input name="bbid" style="width:200px;" type="text" value="">
	        
	        <input onclick="huodonglist(1)" class='self-btn' type="button" value="搜索">
	    </form>
      
    </div>
  
   
    <div >
        <div>	
         	<table id="headtable">
         		<thead></thead>
             	<tbody></tbody>
            </table>
        </div>
        <div id="fanye"></div>
    </div>
</div>

</body>



<script>
	var table = createtable("headtable");
	
	var imgtdfun = function(row){
		var tdinner = "<img style='width:100px;height:100px;' src='"+row.picurl+"'>";
		return tdinner;
	}
	
	var detailfun = function(row){
		return "<button type='button' class='self-btn' onclick='add("+row.id+")'>修改成本价格</button>";
	}
	
	
	table.th = [{w:100,na:"编号",colname:"id"}
	,{w:200,na:"商品主图",callfun:imgtdfun}
	,{w:200,na:"商品名称",colname:"title"}
	,{w:100,na:"货号",colname:"code"}
	,{w:100,na:"累计销售量",colname:"totalSaleNum"}
	,{w:100,na:"剩余库存",colname:"kuCunNum"}
	,{w:100,na:"销售单价",colname:"salePrice"}
	,{w:100,na:"成本单价",colname:"cbPrice"}
	,{w:100,na:"累计销售金额",colname:"sumfenrun"}
	,{w:100,na:"成本金额",colname:"cbjine"}
	,{w:100,na:"分润金额",colname:"frjine"}
	,{w:100,na:"毛利润",colname:"lirun"}
	,{w:100,na:"净利润",colname:"jinlirun"}
	,{w:100,na:"操作",callfun:detailfun}];
	
	table.thinit();
	
	function sucdo(data){
		var rows = data.resultData.rows;
		fanye.init(data.resultData.total);	
		if(rows){	
			table.data = rows;
			table.tdinit();		
		}	
	}

	var fanye = new FanYe("fanye","huodonglist",0,20,1);	
	
   function huodonglist(current){
	   if(!fanye.setpage(current)){
			return;
	 	}
	   var data = formtojson($('#chaxun'));
	   data.pageNo = fanye.current;
	   data.pageSize = fanye.limit;
	   var url = getbaseurl("/order/splrhs.do");
	   postdo(url, data, sucdo,null, null);
   }
 
   huodonglist(1);
   
   function doSearch(){
	   huodonglist(fanye.current);
   }
   
   layui.use('laydate', function(){
	   var laydate = layui.laydate;  
	   //时间控件
	   laydate.render({
		 elem: '#startCreatedTime'
		,type: 'datetime'
	   });
	   laydate.render({
		 elem: '#endCreatedTime'
		,type: 'datetime'
	   });
	});
        
   
   function add(id){	    
	   var str = window.prompt("请输入成本价","");
	   if(str == 0 || str){
		   var data = {id:id,jine:str};
		   var url = getbaseurl("/baobei/updatecb.do");
		   var s = function(redata){
			   doSearch();
		   }
		   postdo(url, data,s,null, null);
	   }	  
	}
</script>


</html>